Imports WindowsLive.Writer.Api

Public Class Settings
  Private _Settings As IProperties
  Private _TemplatePath As String
  Private _LineBreakConversion As LineBreakConverisonOptions = LineBreakConverisonOptions.BRTag

  Private Const PROPERTYKEY_TEMPLATEPATH = "TextTemplatePath"
  Private Const PROPERTYKEY_NEWLINE = "TextTemplateNewLine"
	Private Const PROPERTYKEY_LASTUSEDTEMPLATE = "TextTemplateLastUsedTemplate"

  Public Enum LineBreakConverisonOptions
    NoConversion
    BRTag
  End Enum

  Public Sub New(ByVal settings As IProperties)
    _Settings = Settings
    _TemplatePath = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Windows Live Writer\TextTemplates")

  End Sub

  Public Property TemplatePath() As String
    Get
      Return _Settings.GetString(PROPERTYKEY_TEMPLATEPATH, _TemplatePath)
    End Get
    Set(ByVal value As String)
      _Settings.SetString(PROPERTYKEY_TEMPLATEPATH, value)
    End Set
  End Property

  Public Property LineBreakConversion() As LineBreakConverisonOptions
		Get
			Dim result As Integer = _LineBreakConversion
			Try
				result = _Settings.GetInt(PROPERTYKEY_NEWLINE, _LineBreakConversion)
			Catch ex As Exception

			End Try
			Return result
		End Get
    Set(ByVal value As LineBreakConverisonOptions)
      _Settings.SetInt(PROPERTYKEY_NEWLINE, value)
    End Set
  End Property

	Public Property LastTemplateUsed() As String
		Get
			Return _Settings.GetString(PROPERTYKEY_LASTUSEDTEMPLATE, "")
		End Get
		Set(ByVal value As String)
			_Settings.SetString(PROPERTYKEY_LASTUSEDTEMPLATE, value)

		End Set
	End Property
End Class
